﻿using CJAtech.BBS.Business;
using CJAtech.BBS.DataEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Bigger.Base.Cache;
using Bigger.Framework;
using Bigger.Web.Helper;

namespace CJAtech.BBS.Process
{
    public partial class BBSBaseProcess
    {
        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="articleId">文章Id</param>
        /// <param name="commentID"></param>
        /// <param name="position"></param>
        /// <param name="loadCount"></param>
        /// <param name="isLoadFloor"></param>
        /// <param name="isLoadRelatedRecord"></param>
        /// <returns></returns>
        public virtual InvokeResult GetCommentList(int? articleId, int? commentID, string position, int? loadCount = 10, int? isLoadFloor = 0, int? isLoadRelatedRecord = 1)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!articleId.HasValue)
            {
                objInvokeResult.ResultCode = "ArticleIdNull";
                objInvokeResult.ResultMessage = "文章Id为空";
                return objInvokeResult;
            }
            if (!loadCount.HasValue || loadCount <= 0 || loadCount > 20)
            {
                loadCount = 10;
            }
            BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            List<CommentInfo> objCommentInfoList = null;
            int commentCount = 0;
            if (commentID.HasValue)
            {
                if (position == "top")
                {
                    objCommentInfoList = objBizCommentInfo.GetListCache("", TimeSpan.FromSeconds(5), "ObjectId='" + articleId + "' AND IsAudit=1 AND CommentId>" + commentID, "CommentId asc", "top " + loadCount + " *");
                }
                else
                {
                    objCommentInfoList = objBizCommentInfo.GetListCache("", TimeSpan.FromSeconds(5), "ObjectId='" + articleId + "' AND IsAudit=1 AND CommentId<" + commentID, "CommentId desc", "top " + loadCount + " *");
                }
            }
            else
            {
                objCommentInfoList = objBizCommentInfo.GetList("ObjectId='" + articleId + "' AND IsAudit=1", "CommentId desc", "top " + loadCount + " *");
                commentCount = objBizCommentInfo.GetTotal("ObjectId='" + articleId + "' AND IsAudit=1");
            }
            if (objCommentInfoList.IsNull())
            {
                objInvokeResult.ResultCode = "CommentNull";
                objInvokeResult.ResultMessage = "没有更多评论了";
                return objInvokeResult;
            }
            if (isLoadFloor.HasValue && isLoadFloor.Value == 1)
            {
                LoadCommentFloorList(objCommentInfoList);
            }
            if (isLoadRelatedRecord.HasValue && isLoadRelatedRecord.Value == 1)
            {
                LoadCommentRelatedRecord(objCommentInfoList);
            }
            objInvokeResult.Data = new { CommentList = objCommentInfoList, CommentCount = commentCount };
            return objInvokeResult;
        }

        /// <summary>
        /// 获取热门评论
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadFloor"></param>
        /// <param name="isLoadRelatedRecord"></param>
        /// <returns></returns>
        public virtual InvokeResult GetCommentHotList(int? articleId, int? pageIndex = 1, int? pageSize = 10, int? isLoadFloor = 0, int? isLoadRelatedRecord = 1)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!articleId.HasValue)
            {
                objInvokeResult.ResultCode = "ArticleIdNull";
                objInvokeResult.ResultMessage = "文章Id为空";
                return objInvokeResult;
            }
            if (!pageIndex.HasValue || pageIndex <= 0)
            {
                pageIndex = 1;
            }
            if (!pageSize.HasValue || pageSize <= 0 || pageSize > 20)
            {
                pageSize = 10;
            }
            BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            List<CommentInfo> objCommentInfoList = objBizCommentInfo.GetPageListCache("", TimeSpan.FromSeconds(30), pageIndex.Value - 1, 5, "ObjectId=@ObjectId AND ReplyId=0", new { ObjectId = articleId }, "DiggCount desc");
            if (objCommentInfoList.IsNull())
            {
                objInvokeResult.ResultCode = "CommentHotNull";
                objInvokeResult.ResultMessage = "没有热门评论了";
                return objInvokeResult;
            }
            if (isLoadFloor.HasValue && isLoadFloor.Value == 1)
            {
                LoadCommentFloorList(objCommentInfoList);
            }
            if (isLoadRelatedRecord.HasValue && isLoadRelatedRecord.Value == 1)
            {
                LoadCommentRelatedRecord(objCommentInfoList);
            }
            objInvokeResult.Data = objCommentInfoList;
            return objInvokeResult;
        }

        /// <summary>
        /// 获取评论列表
        /// </summary>
        /// <param name="articleId">文章Id</param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <param name="isLoadFloor"></param>
        /// <param name="isLoadRelatedRecord"></param>
        /// <returns></returns>
        public virtual InvokeResult GetCommentPageList(int? articleId, int? pageIndex = 1, int? pageSize = 10, int? isLoadFloor = 0, int? isLoadRelatedRecord = 1)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!articleId.HasValue)
            {
                objInvokeResult.ResultCode = "ArticleIdNull";
                objInvokeResult.ResultMessage = "文章Id为空";
                return objInvokeResult;
            }
            BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            if (!pageIndex.HasValue || pageIndex <= 0)
            {
                pageIndex = 1;
            }
            if (!pageSize.HasValue || pageSize <= 0 || pageSize > 20)
            {
                pageSize = 10;
            }
            int recordCount = 0;
            List<CommentInfo> objCommentInfoList = objBizCommentInfo.GetPageListCache("", TimeSpan.FromSeconds(5), pageIndex.Value - 1, pageSize.Value, out recordCount, "ObjectId='" + articleId + "' AND IsAudit=1", "CommentId desc");
            if (isLoadRelatedRecord.HasValue && isLoadRelatedRecord.Value == 1)
            {
                LoadCommentRelatedRecord(objCommentInfoList);
            }
            if (isLoadFloor.HasValue && isLoadFloor.Value == 1)
            {
                LoadCommentFloorList(objCommentInfoList);
            }
            objInvokeResult.Data = new { CommentList = objCommentInfoList, CommentCount = recordCount, PageIndex = pageIndex, PageSize = pageSize, PageCount = (int)Math.Ceiling(((double)recordCount / pageSize.Value)) };
            return objInvokeResult;
        }

        /// <summary>
        /// 展开评论楼层列表
        /// </summary>
        /// <param name="commentId"></param>
        /// <param name="previousFloorId"></param>
        /// <param name="floorCount"></param>
        /// <returns></returns>
        public virtual InvokeResult GetCommentRestFloorList(int? commentId, int? previousFloorId, int? floorCount = 20)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!commentId.HasValue)
            {
                objInvokeResult.ResultCode = "CommentIdNull";
                objInvokeResult.ResultMessage = "评论Id为空";
                return objInvokeResult;
            }
            if (!previousFloorId.HasValue)
            {
                objInvokeResult.ResultCode = "PreviousFloorIdNull";
                objInvokeResult.ResultMessage = "上一条评论Id为空";
                return objInvokeResult;
            }
            if (commentId.Value == previousFloorId.Value)
            {
                objInvokeResult.ResultCode = "CommentIdEqualPreviousFloorId";
                objInvokeResult.ResultMessage = "没有更多评论了";
                return objInvokeResult;
            }
            BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            CommentInfo objCommentInfo = objBizCommentInfo.GetRecordCache("", commentId.Value, TimeSpan.FromSeconds(5));
            if (objCommentInfo == null)
            {
                objInvokeResult.ResultCode = "CommentInfoNull";
                objInvokeResult.ResultMessage = "评论不存在";
                return objInvokeResult;
            }
            string strPreviousFloorId = string.Format(",{0},", previousFloorId.Value);
            if (!objCommentInfo.ReplyIdPath.Contains(strPreviousFloorId))
            {
                objInvokeResult.ResultCode = "PreviousFloorNull";
                objInvokeResult.ResultMessage = "上一条评论不存在";
                return objInvokeResult;
            }
            string[] array = objCommentInfo.ReplyIdPath.Split(new string[] { strPreviousFloorId }, StringSplitOptions.RemoveEmptyEntries);
            if (array == null || array.Length == 1)
            {
                objInvokeResult.ResultCode = "FloorSplitNull";
                objInvokeResult.ResultMessage = "没有更多评论了";
                return objInvokeResult;
            }
            string restFloorIds = null;
            if (!floorCount.HasValue || floorCount.Value <= 0 || floorCount.Value > 20)
            {
                floorCount = 20;
            }
            List<string> lisFloorIds = array[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
            lisFloorIds.RemoveRange(lisFloorIds.Count - 2, 2);
            if (lisFloorIds.IsNoNull())
            {
                restFloorIds = lisFloorIds.Take(floorCount.Value).JoinComma();
            }
            if (restFloorIds.IsNull())
            {
                objInvokeResult.ResultCode = "RestFloorIdsNull";
                objInvokeResult.ResultMessage = "没有更多评论了";
                return objInvokeResult;
            }
            List<CommentInfo> objRestFloorList = objBizCommentInfo.GetListInCache("", TimeSpan.FromSeconds(5), restFloorIds);
            if (objRestFloorList.IsNull())
            {
                objInvokeResult.ResultCode = "NoMoreFloors";
                objInvokeResult.ResultMessage = "没有更多评论了";
                return objInvokeResult;
            }
            objInvokeResult.Data = objRestFloorList;
            return objInvokeResult;
        }

        /// <summary>
        /// 轮询是否有最新评论
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="commentID"></param>
        /// <returns></returns>
        public virtual InvokeResult HasCommentLatest(int? articleId, int? commentID)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!articleId.HasValue)
            {
                objInvokeResult.ResultCode = "ArticleIdNull";
                objInvokeResult.ResultMessage = "文章Id为空";
                return objInvokeResult;
            }

            var CurrentCache = Bigger.Core.Cache.CacheHelper.CacheInstance;
            string cacheKey = string.Format("{0}_Article_{1}_LatestComment>{2}", CurrentCommunityConfig.ConfigCode, articleId, commentID);
            object obj = CurrentCache.GetCache(cacheKey);
            if (obj == null)
            {
                BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
                if (commentID.HasValue)
                {
                    obj = objBizCommentInfo.GetField<object>("CommentId>@CommentId AND ObjectId=@ObjectId", new { CommentId = commentID, ObjectId = articleId }, "top 1 CommentId");
                }
                else
                {
                    obj = objBizCommentInfo.GetField<object>("ObjectId=@ObjectId", new { ObjectId = articleId }, "top 1 CommentId");
                }
            }
            if (obj == null)
            {
                objInvokeResult.ResultCode = "HasNoLatest";
                objInvokeResult.ResultMessage = "对不起，没有最新评论";
                return objInvokeResult;
            }
            CurrentCache.SetCache(cacheKey, obj, TimeSpan.FromSeconds(30));

            objInvokeResult.ResultMessage = "有最新的评论";
            return objInvokeResult;
        }

        /// <summary>
        /// 添加评论
        /// </summary>
        /// <param name="articleId"></param>
        /// <param name="replyId"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public virtual InvokeResult AddComment(int? articleId, int? replyId, string content)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!articleId.HasValue)
            {
                objInvokeResult.ResultCode = "ArticleIdEmpty";
                objInvokeResult.ResultMessage = "对不起，文章不存在";
                return objInvokeResult;
            }
            if (content.IsNull())
            {
                objInvokeResult.ResultCode = "ContentEmpty";
                objInvokeResult.ResultMessage = "对不起，评论内容不能为空";
                return objInvokeResult;
            }
            var badwordsList = content.SearchMatchBadWords(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            if (badwordsList.IsNoNull())
            {
                objInvokeResult.ResultCode = "ContentHasBadWords";
                objInvokeResult.ResultMessage = "对不起，评论内容包含敏感信息词汇 " + badwordsList[0];
                return objInvokeResult;
            }

            UserInfo objUserInfo = GetUserInfo();
            var CurrentCache = Bigger.Core.Cache.CacheHelper.CacheInstance;
            string cacheKey = this.CurrentCommunityConfig.ConfigCode + "_LastComment_" + objUserInfo.UserId;
            //获取上一次评论缓存
            CommentInfo objLastCommentInfo = CurrentCache.GetCache<CommentInfo>(cacheKey);
            if (objLastCommentInfo != null && objLastCommentInfo.CreateDate.AddSeconds(5).IsGreaterThanCurrent())
            {
                objInvokeResult.ResultCode = "CommentFrequently";
                objInvokeResult.ResultMessage = "对不起，请你与上次评论间隔5秒";
                return objInvokeResult;
            }

            BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            CommentInfo objRepliedComment = null;
            if (replyId.HasValue)
            {
                objRepliedComment = objBizCommentInfo.GetRecordCache("", replyId.Value, TimeSpan.FromSeconds(5));
                if (objRepliedComment == null)
                {
                    objInvokeResult.ResultCode = "ReplyNull";
                    objInvokeResult.ResultMessage = "对不起，被回复的评论不存在或已删除";
                    return objInvokeResult;
                }
            }

            CommentInfo objCommentInfo = new CommentInfo()
            {
                ObjectId = articleId.Value.ToString(),
                ObjectCode = "Article_" + articleId,
                UserId = objUserInfo.UserId,
                NickName = objUserInfo.UserName.SetNullToDefaultValue(string.Empty),
                Content = content,
                IsAudit = 1,
                UserIP = SystemWebAsset.GetClientIP(),
                CreateDate = DateTime.Now,
                ReplyId = objRepliedComment == null ? 0 : objRepliedComment.CommentId,
                Avatar = objUserInfo.Avatar.SetNullToDefaultValue(string.Empty)
            };

            //设置上一条评论缓存
            CurrentCache.SetCache(cacheKey, objCommentInfo, TimeSpan.FromSeconds(10));

            objInvokeResult.ResultMessage = "评论成功";
            objInvokeResult.Data = objBizCommentInfo.Add(objCommentInfo);
            if (objRepliedComment != null)
            {
                objCommentInfo.ReplyIdPath = objRepliedComment.ReplyIdPath + objCommentInfo.CommentId + ",";
            }
            else
            {
                objCommentInfo.ReplyIdPath = "," + objCommentInfo.CommentId + ",";
            }
            objBizCommentInfo.Update("ReplyIdPath=@ReplyIdPath", objCommentInfo.CommentId, new { ReplyIdPath = objCommentInfo.ReplyIdPath });

            //更新文章的评论数
            BizArticleInfo objBizArticleInfo = new BizArticleInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            objBizArticleInfo.Update("CommentCount=CommentCount+1", articleId.Value);
            return objInvokeResult;
        }

        /// <summary>
        /// 评论点赞
        /// </summary>
        /// <param name="commentId"></param>
        /// <param name="articleId"></param>
        /// <returns></returns>
        public virtual InvokeResult DiggComment(int? commentId, int? articleId)
        {
            InvokeResult objInvokeResult = new InvokeResult();
            if (!commentId.HasValue)
            {
                objInvokeResult.ResultCode = "CommentIdEmpty";
                objInvokeResult.ResultMessage = "对不起，评论不存在";
                return objInvokeResult;
            }
            if (!articleId.HasValue)
            {
                objInvokeResult.ResultCode = "ArticleIdEmpty";
                objInvokeResult.ResultMessage = "对不起，文章不存在";
                return objInvokeResult;
            }
            BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            CommentInfo objCommentInfo = objBizCommentInfo.GetRecordCache("", commentId.Value, TimeSpan.FromSeconds(5));
            if (objCommentInfo == null)
            {
                objInvokeResult.ResultCode = "CommentInfoEmpty";
                objInvokeResult.ResultMessage = "对不起，评论不存在";
                return objInvokeResult;
            }

            UserInfo objUserInfo = GetUserInfo();

            var CurrentCache = Bigger.Core.Cache.CacheHelper.CacheInstance;
            string cacheKey = this.CurrentCommunityConfig.ConfigCode + "_LastDiggComment_" + commentId.Value + objUserInfo.UserId;
            //获取上一次评论缓存
            DiggInfo objLastDiggInfo = CurrentCache.GetCache<DiggInfo>(cacheKey);
            if (objLastDiggInfo != null && objLastDiggInfo.DiggTime.AddSeconds(5).IsGreaterThanCurrent())
            {
                objInvokeResult.ResultCode = "DiggCommentFrequently";
                objInvokeResult.ResultMessage = "对不起，请你与上次点赞该评论的时间间隔5秒";
                return objInvokeResult;
            }

            BizDiggInfo objBizDiggInfo = new BizDiggInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
            object hasDigg = objBizDiggInfo.GetFieldCache<object, DiggInfo, int>("", TimeSpan.FromSeconds(5), "ObjectType='Digg' AND UserId=@UserId AND ObjectId=@ObjectId AND ObjectCode=@ObjectCode", new { UserId = objUserInfo.UserId, ObjectId = commentId.Value, ObjectCode = "Article_Comments_" + articleId }, "DiggId");
            if (hasDigg != null)
            {
                objInvokeResult.ResultCode = "DiggAlready";
                objInvokeResult.ResultMessage = "对不起，你已对该评论点赞过";
                return objInvokeResult;
            }
            DiggInfo objDiggInfo = new DiggInfo
            {
                ObjectId = commentId.Value.ToString(),
                ObjectCode = "Article_Comments_" + articleId,
                ObjectType = "Digg",
                UserId = objUserInfo.UserId,
                UserIP = SystemWebAsset.GetClientIP(),
                DiggTime = DateTime.Now
            };

            //设置上一条缓存
            CurrentCache.SetCache(cacheKey, objDiggInfo, TimeSpan.FromSeconds(10));

            objBizDiggInfo.Add(objDiggInfo);

            //更新评论点赞
            objBizCommentInfo.Update("DiggCount=DiggCount+1", objCommentInfo.CommentId);

            objInvokeResult.ResultMessage = "点赞成功";
            return objInvokeResult;
        }

        /// <summary>
        /// 加载评论的相关操作
        /// </summary>
        /// <param name="objList"></param>
        public virtual void LoadCommentRelatedRecord(List<CommentInfo> objList)
        {
            if (objList.IsNoNull())
            {
                UserInfo objUserInfo = GetUserInfo();
                BizDiggInfo objBizDiggInfo = new BizDiggInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
                string objectIDs = objList.Select(c => c.CommentId).JoinComma().ConvertVarcharString();
                List<DiggInfo> objDiggInfoList = objBizDiggInfo.GetListCache("", TimeSpan.FromSeconds(5), string.Format("ObjectId in({0}) AND UserId='{1}'", objectIDs, objUserInfo.UserId));
                if (objDiggInfoList.IsNoNull())
                {
                    foreach (CommentInfo objCommentInfo in objList)
                    {
                        objCommentInfo.IsDigg = objDiggInfoList.Any(c => String.Equals(c.ObjectType, "Digg", StringComparison.OrdinalIgnoreCase));
                        objCommentInfo.IsBury = objDiggInfoList.Any(c => String.Equals(c.ObjectType, "Bury", StringComparison.OrdinalIgnoreCase));
                    }
                }
            }
        }


        /// <summary>
        /// 加载评论回复列表
        /// </summary>
        /// <param name="objList"></param>
        /// <param name="floorCount"></param>
        public virtual void LoadCommentFloorList(List<CommentInfo> objList, int? floorCount = 3)
        {
            if (objList.IsNull())
            {
                return;
            }
            if (!floorCount.HasValue || floorCount.Value <= 0 || floorCount.Value > 20)
            {
                floorCount = 3;
            }

            List<string> strFloorIds = null;
            FloorCommentInfo objFloorCommentInfo = null;
            List<FloorCommentInfo> objFloorCommentInfoList = new List<FloorCommentInfo>();
            foreach (CommentInfo objCommentInfo in objList)
            {
                if (objCommentInfo.ReplyId == 0)
                {
                    continue;
                }
                objFloorCommentInfo = new FloorCommentInfo
                {
                    CommentId = objCommentInfo.CommentId
                };
                strFloorIds = objCommentInfo.ReplyIdPath.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                //移除最后一个
                strFloorIds.Remove(objCommentInfo.CommentId.ToString());
                //添加倒数第二个（移除后是最后一个）
                objFloorCommentInfo.FloorIds.Add(strFloorIds.Last());
                //添加前floorCount-1楼层
                objFloorCommentInfo.FloorIds.AddRange(strFloorIds.Take(floorCount.Value - 1));
                objFloorCommentInfo.FloorIds = objFloorCommentInfo.FloorIds.Distinct().ToList();
                objFloorCommentInfoList.Add(objFloorCommentInfo);
            }
            List<string> objFloorIds = objFloorCommentInfoList.SelectMany(c => c.FloorIds).Distinct().ToList();
            if (objFloorIds.IsNoNull())
            {
                CommentInfo objCommentInfoExist = null;
                List<CommentInfo> objFloorList = new List<CommentInfo>();
                int floorIdCount = objFloorIds.Count;
                for (int i = floorIdCount - 1; i >= 0; i--)
                {
                    objCommentInfoExist = objList.FirstOrDefault(c => string.Equals(objFloorIds[i], c.CommentId.ToString()));
                    if (objCommentInfoExist != null)
                    {
                        //若现有评论已有回复的评论，从内存取
                        //数据库和CPU性能 两者选一
                        objFloorList.Add(objCommentInfoExist.JsonSerialize().JsonDeserialize<CommentInfo>());
                        objFloorIds.Remove(objFloorIds[i]);
                    }
                }
                if (objFloorIds.IsNoNull())
                {
                    BizCommentInfo objBizCommentInfo = new BizCommentInfo(CurrentCommunityConfig.ConnectionStringKey, CurrentCommunityConfig.DataObjectParam);
                    //剩下的回复读数据库
                    List<CommentInfo> objRest = objBizCommentInfo.GetListInCache("", TimeSpan.FromSeconds(10), objFloorIds.JoinComma());
                    if (objRest.IsNoNull())
                    {
                        objFloorList.AddRange(objRest);
                    }
                }
                foreach (CommentInfo objCommentInfo in objList)
                {
                    if (objCommentInfo.ReplyId == 0)
                    {
                        continue;
                    }
                    objFloorCommentInfo = objFloorCommentInfoList.FirstOrDefault(c => c.CommentId == objCommentInfo.CommentId);
                    if (objFloorCommentInfo == null)
                    {
                        continue;
                    }
                    //组织评论回复
                    objCommentInfo.FloorList = objFloorList.Join(objFloorCommentInfo.FloorIds, c1 => c1.CommentId, c2 => Convert.ToInt32(c2), (c1, c2) => c1).OrderBy(c => c.CommentId).ToList();
                }
            }
        }

        class FloorCommentInfo
        {
            public int CommentId { get; set; }
            public List<string> FloorIds { get; set; }
            public FloorCommentInfo()
            {
                this.FloorIds = new List<string>();
            }
        }
    }
}
